package net.hn.hnms.biz.safety.fire.group.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import net.hn.hnms.biz.api.safety.support.domain.MineNowAlarmVo;
import net.hn.hnms.biz.safety.fire.company.domain.vo.SGJCAlarmVo;
import net.hn.hnms.biz.safety.fire.group.service.GroupFireService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author 智呈物联 nzw
 * @date 2022/7/28
 */
@RestController
@RequestMapping("group/riskWarning/sgjc")
@AllArgsConstructor
@Api(value = "火灾监测接口-集团端", tags = {"束管监测-集团端"})
public class GroupFireController {
    private final JdbcTemplate jdbcTemplate;


    @Resource
    private GroupFireService groupFireService;
    @GetMapping("nowAlarm")
    @ApiOperation("束管监测各煤矿报警信息")
    public List<MineNowAlarmVo> nowAlarm() {
        String sql = "SELECT mine_code AS mineCode,\"count\"(1) AS COUNT FROM \"ods_sgjc_his_sensormonitor\" " +
                "where sampling_time>CURRENT_DATE AND  \"state\"!='No'  GROUP BY mine_code";

        return jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(MineNowAlarmVo.class));
    }
    @GetMapping("/getTodaySGJCAlarmList")
    @ApiOperation("获取今日束管监测报警列表(内因火灾)")
    @AutoSetMineCode
    public R<List<SGJCAlarmVo>> getTodaySGJCAlarmList(){
        List<SGJCAlarmVo>  list= groupFireService.getTodaySGJCAlarmList();
        return R.ok(list);
    }
}
